package com.situ.mall.common.exception;

import com.situ.mall.common.util.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalException {
	
	//全局异常处理 Exception是所有异常的父类
	@ExceptionHandler(value = Exception.class)
	@ResponseBody
	public Result error(Exception e) {
		e.printStackTrace();
		return Result.error(e.getMessage());
	}
	
	//配置自定义异常
	@ExceptionHandler(value = SituException.class)
	@ResponseBody
	public Result error(SituException e) {
		e.printStackTrace();
		return Result.error(e.getMessage());
	}
}
